use ActionTestHelper;
use Action;
use ResourceManager;

$rm = ResourceManager->new();
$am = $rm->getComponent("ActionManager");

$action = $am->newAction("Test",{IS_OK => 1});

print "\n\n";
testClass($action, "TestAction");

testInjection($action, $am, "ActionManager");

$dm = $rm -> getComponent("DisplayManager");
testInjection($action, $dm, "DisplayManager");


print "\n\n";
$expectedStatus = "DONE";
$expectedMessage = "Done";
testPerform($action, $expectedStatus, $expectedMessage);


print "\n\n";
$expectedStatus = "SUCCESS";
$expectedMessage = "OK";
testValidate($action, $expectedStatus, $expectedMessage);

print "\n\n";


$params = {};
$action->params($params);

testClass($action->params, "HASH");
testParamIdentity($action, $params);


 ## TESTING PARAMETER PASSING
@actionParamNames = ("ONE", "TWO", "DIR");
@actionParamValues = ("1", "2", "UP");
$lastParamName = "BOOLEAN";

$actionName = "Test";

for(my $i = 0; $i<(scalar(@actionParamNames)); $i++){
    $actionName .= "|".@actionParamNames[$i]."=".@actionParamValues[$i];
}
$actionName.="|".$lastParamName;

@otherActionParamNames  = ("ANOTHERONE", "LAST");
@otherActionParamValues = (1, "lastone");
$otherParams = {};
for(my $i = 0; $i<(scalar(@actionParamNames)); $i++){
    $otherParams->{@otherActionParamNames[$i]} = @otherActionParamValues[$i];
}

$action = $am->newAction($actionName, $otherParams);
@names = (@actionParamNames, $lastParamName, @otherActionParamNames);
@values = (@actionParamValues, 1, @otherActionParamValues);

testActionParameters($action, \@names, \@values);

